package top.zimang.loveforwords;

import android.Manifest;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.ServiceConnection;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.IBinder;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;

import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat;

import top.zimang.loveforwords.Activity.SearchWordsActivity;
import top.zimang.loveforwords.Base.BaseActivity;
import top.zimang.loveforwords.Service.SearchForWords;

public class MainActivity extends BaseActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        Button seachButt=(Button) findViewById(R.id.search_button);
        seachButt.setOnClickListener(this::onClick);
        Button changeBut=(Button) findViewById(R.id.changeBut);
        changeBut.setOnClickListener(this::onClick);
        if (ContextCompat.checkSelfPermission(MainActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE)!= PackageManager.PERMISSION_GRANTED){
            ActivityCompat.requestPermissions(MainActivity.this,
                    new String[]{
                            Manifest.permission.WRITE_EXTERNAL_STORAGE
                    },1
            );
        }
    }

    @Override
    public void onClick(View view) {
        super.onClick(view);
        switch (view.getId()){
            case R.id.search_button:
                Intent intent=new Intent(this, SearchWordsActivity.class);
                startActivity(intent);
                break;
            case R.id.changeBut:
                LinearLayout layout=(LinearLayout) findViewById(R.id.main_act);
                layout.setBackgroundResource(R.drawable.pica);
                break;
            default:
                break;
        }
    }


}